
import 'package:flutter/cupertino.dart';

class ParamDemo extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    //dart 可选参数的方法类型.
    //可选参数必选参数必须在前面
    getPart1("大括号", name: "小米", pwd: "123");
    getPart1("大括号", pwd: "123");
    getPart2("小括号", "华为", "123");
    getPart2("小括号", "123");
    return Text("Param demo");
  }

}

/**
 * 带有大括号的:传值比较明确.
 */
getPart1(var a, {String? name, String? pwd}) {
  print("a=$a name=$name pwd=$pwd");
}

/**
 * 中括号的:默认按照顺序
 */
getPart2(var a, [String? name, String? pwd]) {
  print("a=$a name=$name pwd=$pwd");
}
getPart3([String? name, String? pwd]) {
  print("name=$name pwd=$pwd");
}

/**
 * 默认参数值
 */
getDeful(String a, {String name="小明", String pwd="123"} ){

}